﻿using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain.Repositories;
using YAPACS.BusinessObjects.Exams;
using YAPACS.Workflows;

namespace YAPACS.RisServer.Workflows.Register;

public class CreateExam(IRepository<Patient, Guid> patientRepository) : WorkflowBase, ICreateExam, ITransientDependency
{
    private readonly IRepository<Patient, Guid> _patientRepository = patientRepository;
    protected override async Task<WorkflowOutput> InvokeCoreAsync(WorkflowInput input)
    {
        const string key = "Exam";

        if (input.ContainsKey(key) && input.GetValueOrDefault(key) is Exam exam)
        {
            //exam.Patient =await _patientRepository.FirstAsync();
            //exam.AgeValue = 20;
            //为exam赋值
            return await Task.FromResult(new WorkflowOutput
            {
                Success = true,
                Data = exam.Oid
            });
        }

        return await Task.FromResult(new WorkflowOutput
        {
            Success = false,
            Error = "未找到Exam对象",
            //Data = null
        });
    }
}
